package com.pay.sdk;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.pay.sdk.common.Configure;
import com.pay.sdk.service.real.RealLiquidateService;
import com.pay.sdk.util.RandomStringGenerator;

/**
 * 代付V2
 * 
 * @author Administrator
 *
 */
public class RealLiquidateExample {

	public static void main(String[] args) {
		System.out.println("==重要== 调用任何API前，请先配置Configure类");
		// 使用测试环境，生产上使用请设置为false
//		 Configure.setDevEnv(false);
	     Configure.setMerchantNo("648760778763300864");
	     Configure.setKey("6938ebb3704f4e95bc06517f3e8b3717");
//		 payOtherExample(); //单笔代付
		 payOtherQueryExample(); //单笔代付结果查询
//		 bankTypeQueryExample();
//		bankCardExample();//银行卡信息查询
//		 TuiHuiQueryExample(); 

	}


	public static void payOtherExample() {
		try {
			String out_trade_no = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
			String account_type = "00";
			String account_name = "杨学勇";// 账号名
			String account_no = "6228480089507246372";// 账号
			String id_type = "0";
			String id = "522631198702280017";// 身份证
			String tel = "18200982382";
			String bank_code = "103";
			String client_ip = "127.0.0.1";
			String pay_trans_no = "650129728950677504";
			String nonce_str =RandomStringGenerator.getRandomStringByLength(32) ;
			
			String notify_url = "";//保留
			String refund_notify_url="";//保留
			String bank_type = "";// 联行号
			String account_prop = "0";//默认0
			String attach = "";
			String currency = "";
			String result = RealLiquidateService.payOther(out_trade_no, account_type, account_name, account_no,
					id_type, id, tel, bank_code,client_ip,nonce_str, account_prop, bank_type,notify_url,refund_notify_url,attach,currency,pay_trans_no);
			System.out.println("单笔代付：" + result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void bankTypeQueryExample() {
		try {
			String bank_code = "102";
			String province = "广东省";
			String city = "广州市";
			String branch_name = "天河客运站";
			String nonce_str =RandomStringGenerator.getRandomStringByLength(32) ;

			String result = RealLiquidateService.bankTypeQuery(bank_code, province, city, branch_name,nonce_str);
			System.out.println("代付查询：" + result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
	public static void payOtherQueryExample() {
		try {
			String out_trade_no = "2017070618104";
			String nonce_str =RandomStringGenerator.getRandomStringByLength(32) ;
			String result = RealLiquidateService.payOtherQuery(out_trade_no,nonce_str);
			System.out.println("代付查询：" + result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
//	public static void bankTypeQueryExample() {
//		try {
//			String bank_code = "102";
//			String province = "广东省";
//			String city = "广州市";
//			String branch_name = "天河";
//			String result = LiquidateService.bankTypeQuery(bank_code, province, city, branch_name);
//			System.out.println("代付查询：" + result);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}


	public static void bankCardExample() {
		String card_no = "622848008950724637";
		String nonce_str =RandomStringGenerator.getRandomStringByLength(32) ;
		String result = RealLiquidateService.bankCardQuery(card_no,nonce_str);
		System.out.println(result);
	}

	/**
	 * 代付退汇查询
	 * 
	 * @param begin_date
	 *            开始日期
	 * @param end_date
	 *            结束日期
	 */
	public static void TuiHuiQueryExample() {
		try {
			String begin_date = "20170511";
			String end_date = "20170511";
			String out_trade_no = "";
			String nonce_str =RandomStringGenerator.getRandomStringByLength(32) ;
			String result = RealLiquidateService.queryTh(begin_date, end_date, out_trade_no, nonce_str);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
